﻿using System;
using COM.DTO;
using NHibernate;
using COM.Logging;
using NHibernate.Criterion;
using System.Collections.Generic;

namespace DAL.DAO
{
    class DiscountTypeDAO
    {
        public static void Add(DiscountType discountType)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(discountType);
                    transaction.Commit();
                }
            }
        }
        public static void Update(DiscountType discountType)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Update(discountType);
                    transaction.Commit();
                }
            }
        }

        public static void Remove(DiscountType discountType)
        {
            {
                using (ISession session = NHibernateHelper.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Delete(discountType);
                    transaction.Commit();
                }
            }
        }

        public static DiscountType GetDiscountTypeById(String discountTypeId)
        {
            using (ISession session = NHibernateHelper.OpenSession())
                return session.Get<DiscountType>(discountTypeId);
        }
        
    }
}
